﻿(function($) {
    var methods = {
        show: function(options) {
            return this.each(
        function() {
            var $this = $(this);
            if ($this.data('masklayer')) return;
            var opts = $.extend(true, {}, { zIndex: 99, Text: 'Loading...' }, options);
            var m = $("<div id='masklayer' style='position:absolute;top:0pt;left:0pt;right:0pt;bottom:0pt;'><div>").appendTo($this);
            if (!isNaN(opts.zIndex)) { m.css('z-index', opts.zIndex) }
            $(this).data('masklayer', m);
        });
        },

        hide: function() {
            return this.each(function() {
                var $this = $(this);
                var m = $this.data('masklayer');
                if (m) {
                    m.remove();
                    $(this).removeData('masklayer');
                }
            });
        }
    };
    $.fn.masklayer = function(method) {

        // Method calling logic
        if (methods[method]) {
            return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
        } else if (typeof method === 'object' || !method) {
            return methods.show.apply(this, arguments);
        } else {
            $.error('Method ' + method + ' does not exist on jQuery.SplitterContainer');
        }

    };
})(jQuery);